package mGraph;

import java.util.Hashtable;
import java.util.Set;


/**
 * 
 * @author Giulio Rossetti
 *
 */
public class MTNodeSet {

	private Hashtable<Integer,Integer> set;
	
	
	public MTNodeSet(){
		this.set = new Hashtable<Integer,Integer>();
	}
	
	/**
	 * Add a node to the set
	 * 
	 * @param nodeid Identifier of the node
	 * @param timestamp Temporal id of appareance  
	 */
	public void addMTNode(int nodeid,int timestamp){
		if(!this.set.containsKey(nodeid)) this.set.put(nodeid, timestamp);
	}
	
	/**
	 * Return the nodes in the set
	 * 
	 * @return
	 */
	public Set<Integer> getNodes(){
		return this.set.keySet();
	}
	
	/**
	 * Return the timestamp of appareance in the network of a specific node
	 * 
	 * @param nodeid Identifier of the node
	 * @return
	 */
	public int getTimestamp(int nodeid){
		return this.set.get(nodeid);
	}
	
	/**
	 * Verify the presence of a given node
	 * 
	 * @param nodeid Identifier of the node
	 * @return true if the node belong to the set, false otherwise
	 */
	public boolean containsNode(int nodeid){
		return this.set.containsKey(nodeid);
	}

	/**
	 * Remove the given node form the set
	 * 
	 * @param nodeid Identifier of the node
	 */
	public void remove(int nodeid) {
		this.set.remove(nodeid);
	}
	
	public Object clone(){
		return this.clone();
		
	}
	
}
